#include "customtimevalueaxis.h"

CustomTimeValueAxis::CustomTimeValueAxis(int pointsPerSecond, QObject *parent)
    : QValueAxis(parent), _pointsPerSecond(pointsPerSecond) {
    // 构造函数，初始化每秒对应的点数
}

QString CustomTimeValueAxis::tickLabel(qreal value, const QString &format) {
    // 将数值转换为时分秒格式
    int totalSeconds = static_cast<int>(value / _pointsPerSecond); // 根据点数比例计算总秒数
    int hours = totalSeconds / 3600;
    int minutes = (totalSeconds % 3600) / 60;
    int seconds = totalSeconds % 60;
    return QString("%1:%2:%3").arg(hours, 2, 10, QChar('0'))
        .arg(minutes, 2, 10, QChar('0'))
        .arg(seconds, 2, 10, QChar('0'));
}
